import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:liuxlcommon/lget/lget.dart';
import 'package:liuxlcommon/util/toast_util.dart';
import 'package:liuxlcommon/view/lxl_widget.dart';
import 'package:liuxlcommon/view/my_box.dart';
import 'package:ladder_cash/app/com/view/common_view.dart';
import 'package:ladder_cash/app/com/view/my_app_bar2.dart';
import 'package:ladder_cash/app/page/index/sign_in_view.dart';
import 'package:ladder_cash/generated/assets.dart';
import 'package:ladder_cash/generated/l10n.dart';
import 'package:ladder_cash/value/app_const.dart';

class SignInBoardView extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _();
}

class _ extends State<SignInBoardView> {
  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: MyAppBarTransparent(S.current.appName),
        extendBodyBehindAppBar: true,
        body: LStack([
          LImage.easy(Assets.molopNewBarbg, LGet.areaHeight),
          LColumn.eazy([
            LSizeH(LGet.areaHeight),
            LExpand(
                child: ListView(padding: EdgeInsets.zero, children: [
              Signinview('My gold coin'),
              LText.easy('Sign in to get gold coins', 12.sp, null,
                      Color(0xFF999999))
                  .bgColor(Colors.white)
                  .padding(left: 15.w)
                  .size(375.w, 30.w),
              couponView,
              LSizeH(LGet.bottomPadding(context))
            ]))
          ])
        ]),
      );

  get couponView {
    return LStack([
      LImage.easy(Assets.molopNewCouponlisttopbg, 186.w, 375.w),
      Positioned(
          top: 58.w,
          left: 15.w,
          child: LImage.easy(Assets.molopNewCouponlisttopbg2, 393.w, 345.w)
              .radiusOnly(topRight: 5.w, topLeft: 5.w)),
      LColumn.eazy([
        78.lsh,
        for (var item in Signinview.getCouponList()) ...[citemv(item), 15.lsh]
      ])
    ]).bgColor(Color(0xFFDDEAFF));
  }

  citemv(item) {
    return LRow.eazy([
      LColumn.eazy([
        LText.easy("\$${item['dayCount']}", 30.sp, FontWeight.w900,
                Color(0xFFFA9A09))
            .padding(left: 15.w)
            .size(null, 36.w),
        LText.easy('Repayment can be offset', 11.sp, null, Color(0xFF111111))
            .padding(left: 15.w),
        LExpand(),
        LRow.eazy([
          LImage.easy(Assets.molopNewGoldcoin, 15.w, 15.w),
          LText.easy(item['coinNumber'], 15.sp, fw7, Colors.white)
              .paddingH(4.w),
          LText.easy('Can be exchanged', 12.sp, fw4, Colors.white),
        ])
            .size(null, 23.w)
            .padding(left: 18.w, right: 24.w)
            .radiusOnly(topRight: 20.w, bottomRight: 20.w)
            .bgColor(Color(0xFF3C83FF))
      ]).align(Alignment.topLeft).flex(1),
      LText.easy('Exchange', 13.sp, fw7, Colors.white)
          .radius(5.w)
          .center()
          .size(80.w, 29.w)
          .gradient([Color(0xFFFA9A09), Color(0xFFEE6156)],
              Alignment.centerRight).marginH(12.w)
    ])
        .margin(left: 30.w)
        .bgImg(Assets.molopNewCouponitemtopbg)
        .size(315.w, 84.w)
        .onTapL(() {
      var singinData  = Signinview.getSinginData();
      if (singinData['allCoinNumber'] <= item['coinNumber']) {
        ToastUtils.toast('Not enough coins');
        return;
      }
      singinData['allCoinNumber'] = singinData['allCoinNumber'] -  item['coinNumber'];
      Signinview.setSiginData(singinData);
      setState(() {

      });
      CommonView.commDialog(
          width: 328.w,
          bgImg: Assets.molopNewDhcg, height: 293.w, confirm: () {
        Get.back();

      });
    });
  }
}
